﻿<%@ Page Title="重置密码" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="ResetPassword.aspx.cs" Inherits="RegexLib.Web.Views.Member.ResetPassword" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="box">
	<div class="bt">重置密码</div>
	<div class="bc">
	<form id="TheForm" action="/Member/ResetPasswordSubmit/" method="post">
		<input type="hidden" name="userId" value='<%= ViewData["UserId"] %>' />
		<input type="hidden" name="applyCode" value='<%= ViewData["ApplyCode"] %>' />
		<table>
			<tr><td>请输入密码：</td><td><input type="password" name="userPassword" maxlength="32" class="input" /></td></tr>
			<tr><td>再次输入密码：</td><td><input type="password" name="userPassword2" maxlength="32" class="input"</td></tr>
		</table>
	</form>
	<p><button id="SubmitBtn">确定</button></p>
	<p><span id="MsgSpan"></span></p>
	</div>
</div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript">
var c_TheForm;
var c_SubmitBtn;
var c_MsgSpan;

function GetElements()
{
	c_TheForm = YAHOO.util.Dom.get("TheForm");
	c_SubmitBtn = YAHOO.util.Dom.get("SubmitBtn");
	c_MsgSpan = YAHOO.util.Dom.get("MsgSpan");
}

function SetErrMsg(msg)
{
	c_MsgSpan.className = "err";
	c_MsgSpan.innerText = msg;
}

function SetSucMsg(msg)
{
	c_MsgSpan.className = "suc";
	c_MsgSpan.innerText = msg;
}

function DoSubmit()
{
	c_SubmitBtn.disabled = true;
	
	var callback =
	{
		success: function(o)
		{
			try
			{
				var data = YAHOO.lang.JSON.parse(o.responseText);
				if(data.IsError)
				{
					SetErrMsg(data.Message);
					c_SubmitBtn.disabled = false;
				}
				else
				{
					SetSucMsg(data.Message);
					c_TheForm.reset();
				}
			}
			catch(e)
			{
				SetErrMsg("解析响应时出错，请稍后再试。");
				c_SubmitBtn.disabled = false;
			}
		},
		failure: function(o)
		{
			SetErrMsg("连接错误。");
			c_SubmitBtn.disabled = false;
		},
		timeout: 30000
	};
	
	YAHOO.util.Connect.setForm(c_TheForm);
	YAHOO.util.Connect.asyncRequest("POST", "/Member/ResetPasswordSubmit/", callback, null);
}

function init()
{
	GetElements();
	YAHOO.util.Event.addListener(c_SubmitBtn, "click", DoSubmit);
}

YAHOO.util.Event.onDOMReady(init);
</script>
</asp:Content>
